package com.hangim.pce.common.persistence.dao.impl;

import com.hangim.pce.common.domain.IdEntity;
import com.hangim.pce.common.persistence.dao.BaseEntityDao;
import org.springframework.jdbc.support.KeyHolder;

import java.io.Serializable;

/**
 * @see BaseEntityDao
 */
@SuppressWarnings({"unchecked"})
public abstract class BaseEntityDaoImpl<T extends IdEntity, PK extends Serializable> extends BaseDaoImpl implements BaseEntityDao<T, PK> {
    /**
     * @see BaseEntityDao#getKey(KeyHolder keyHolder, T t)
     */
    @Override
    public Long getKey(KeyHolder keyHolder, T t) {
        long key = keyHolder.getKey().longValue();
        t.setId(key);
        return key;
    }
}
